<?php
/**
 * Unfuddle Person Model
 * Users are represented in the Unfuddle API by the "Person" data model. This
 * class contains the properties that make up a "Person".
 *
 * @package     Unfuddle
 * @subpackage  Data Models
 * @author      Luke Visinoni <luke.visinoni@gmail.com>
 * @copyright   (c) 2010 Luke Visinoni <luke.visinoni@gmail.com>
 * @version     $Id: Person.php 29 2011-05-09 07:08:53Z luke.visinoni $
 */
class Unfuddle_Model_Person extends Unfuddle_Model_Abstract {

    /**
     * Returns a collection of all people within the account
     */
    const URI_PEOPLE = '/people';
    
    /**
     * Access a person by id
     */
    const URI_PERSON_BY_ID = '/people/%d';
    
    /**
     * Returns a collection of people with access to the specified project
     */
    const URI_PROJECT_PEOPLE = '/projects/%d/people';
    
    /**
     * The collection represents all Project Involvements for the given Person.
     * @todo I'm not 100% sure exactly how these work or what they do...
     */
    const URI_PEOPLE_INVOLVEMENTS = '/people/%d/involvements';
    const URI_PEOPLE_INVOLVEMENTS_BY_ID = '/people/%d/involvements/%d';
    const URI_PROJECT_INVOLVEMENTS = '/projects/%d/involvements';
    const URI_PROJECT_INVOLVEMENTS_BY_ID = '/projects/%d/involvements/%d';
    
    /**
     * Retreive the person who is currently accessing the API
     */
    const URI_PERSON_CURRENT = '/people/current';
    
    /**
     * @var string Model name
     */
    protected $_name = 'person';
    
    /**
     * @var array Model fields
     */
    protected $_fields = array(
        'access-key' => array('type' => 'text', 'required' => false, 'read-only' => true),
        'account-id' => array('type' => 'integer', 'required' => false, 'read-only' => true),
        'created-at' => array('type' => 'datetime', 'required' => false, 'read-only' => true),
        'email' => array('type' => 'text', 'required' => false, 'read-only' => false),
        'first-name' => array('type' => 'text', 'required' => false, 'read-only' => false),
        'id' => array('type' => 'integer', 'required' => false, 'read-only' => true),
        'is-administrator' => array('type' => 'boolean', 'required' => false, 'read-only' => false),
        'is-removed' => array('type' => 'boolean', 'required' => false, 'read-only' => false),
        'last-name' => array('type' => 'text', 'required' => false, 'read-only' => false),
        'last-signed-in' => array('type' => 'datetime', 'required' => false, 'read-only' => true),
        'last-signed-in-formatted' => array('type' => 'datetime', 'required' => false, 'read-only' => true), // This field is not available unless formatted=true is passed thru GET
        'notification-frequency' => array('type' => 'set', 'required' => false, 'read-only' => false, 'set' => array('immediate', '30mins', 'hourly', 'dailyam', 'dailypm', 'never')),
        'notification-ignore-self' => array('type' => 'boolean', 'required' => false, 'read-only' => false),
        'notification-last-sent' => array('type' => 'datetime', 'required' => false, 'read-only' => false),
        'notification-scope-messages' => array('type' => 'set', 'required' => false, 'read-only' => false, 'set' => array('all', 'none')),
        'notification-scope-milestones' => array('type' => 'set', 'required' => false, 'read-only' => false, 'set' => array('all', 'none')),
        'notification-scope-source' => array('type' => 'set', 'required' => false, 'read-only' => false, 'set' => array('all', 'none')),
        'notification-scope-tickets' => array('type' => 'set', 'required' => false, 'read-only' => false, 'set' => array('all', 'involved', 'none')),
        'show-help-messages' => array('type' => 'boolean', 'required' => false, 'read-only' => false),
        'text-markup' => array('type' => 'set', 'required' => false, 'read-only' => false, 'set' => array('markdown', 'textile', 'plain')),
        'time-zone' => array('type' => 'text', 'required' => false, 'read-only' => false),
        'updated-at' => array('type' => 'datetime', 'required' => false, 'read-only' => true),
        'username' => array('type' => 'text', 'required' => false, 'read-only' => false),
        
        // not in docs...
        'identity-url' => array('type' => 'text', 'required' => false, 'read-only' => false),
        'notification-scope-notebooks' => array('type' => 'set', 'required' => false, 'read-only' => false, 'set' => array('all', 'none')),
    );

}
